package wapper;

public class IntegerDemo {
    public static void main(String[] args) {
        int a = 123;
        Integer i1 = new Integer(a);
        Integer i2 = new Integer(a);
        //Interger的valueOf()方法总是重用1字节之内（-128-127）之间的Integer对象
        Integer i3 = Integer.valueOf(a);
        Integer i4 = Integer.valueOf(a);
        System.out.println(i1 == i2);
        System.out.println(i1.equals(i2));
        System.out.println(i3 == i4);
        System.out.println(i3.equals(i4));

        System.out.println("===========");
        double d = 123.123;
        Double d1 = Double.valueOf(d);
        Double d2 = Double.valueOf(d);
        System.out.println(d1 == d2);
        System.out.println(d1.equals(d2));

        int i = i1.intValue();
        System.out.println(i);
        byte b = i1.byteValue();//大转小可能溢出
        System.out.println(b);
        double d3 = i1.doubleValue();
        System.out.println(d3);



    }
}
